package ils.domain.catalog.model;

import java.util.List;

import javax.persistence.*;

import org.hibernate.annotations.GenericGenerator;

@Entity
@Table(name = "books")
public class Book
{
    private Integer id;
    private String       title;
    private String       author;
    private String       description;
    private String       publisher;
    private String       volume;
    private String       edition;
    private Integer      pages;
    private String       isbn;
    private String       issn;
    private Category     category;
    private List<String> topics;
    private Integer totalCount;
    private Integer availableCount;
    private String bookType;
    private Integer categoryId;
    private String imageUrl;
    private String link;
    private Integer publishYear;
    private Integer ratingsCount;
    private Integer ratingsSum;

    @Id
    @GeneratedValue(generator = "increment")
    @GenericGenerator(name = "increment", strategy = "increment")
    public Integer getId()
    {
        return id;
    }

    public void setId(Integer id)
    {
        this.id = id;
    }

    public String getTitle()
    {
        return title;
    }

    public void setTitle(String title)
    {
        this.title = title;
    }

    public String getAuthor()
    {
        return author;
    }

    public void setAuthor(String author)
    {
        this.author = author;
    }

    @Column(columnDefinition = "text")
    public String getDescription()
    {
        return description;
    }

    public void setDescription(String description)
    {
        this.description = description;
    }

    public String getPublisher()
    {
        return publisher;
    }

    public void setPublisher(String publisher)
    {
        this.publisher = publisher;
    }

    public String getVolume()
    {
        return volume;
    }

    public void setVolume(String volume)
    {
        this.volume = volume;
    }

    public String getEdition()
    {
        return edition;
    }

    public void setEdition(String edition)
    {
        this.edition = edition;
    }

    public Integer getPages()
    {
        return pages;
    }

    public void setPages(Integer pages)
    {
        this.pages = pages;
    }

    public String getIsbn()
    {
        return isbn;
    }

    public void setIsbn(String isbn)
    {
        this.isbn = isbn;
    }

    public String getIssn()
    {
        return issn;
    }

    public void setIssn(String issn)
    {
        this.issn = issn;
    }

    //@ManyToOne(cascade={CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH})
    //@JoinColumn(name="categoryId")
    @Transient
    public Category getCategory()
    {
        return category;
    }

    public void setCategory(Category category)
    {
        this.category = category;
    }

    @ElementCollection(fetch = FetchType.EAGER)
    @CollectionTable(name="book_topics", joinColumns=@JoinColumn(name="bookId"))
    @Column(name="topicName")
    public List<String> getTopics()
    {
        return topics;
    }

    public void setTopics(List<String> topics)
    {
        this.topics = topics;
    }

    public Integer getTotalCount()
    {
        return totalCount;
    }

    public void setTotalCount(Integer totalCount)
    {
        this.totalCount = totalCount;
    }

    public Integer getAvailableCount()
    {
        return availableCount;
    }

    public void setAvailableCount(Integer availableCount)
    {
        this.availableCount = availableCount;
    }

    public String getBookType() {
        return bookType;
    }

    public void setBookType(String bookType) {
        this.bookType = bookType;
    }

    public Integer getCategoryId() {
        return categoryId;
    }

    public void setCategoryId(Integer categoryId) {
        this.categoryId = categoryId;
    }

    public String getImageUrl() {
        return imageUrl;
    }

    public void setImageUrl(String imageUrl) {
        this.imageUrl = imageUrl;
    }

    public String getLink() {
        return link;
    }

    public void setLink(String link) {
        this.link = link;
    }

    public Integer getPublishYear() {
        return publishYear;
    }

    public void setPublishYear(Integer publishYear) {
        this.publishYear = publishYear;
    }

    public Integer getRatingsCount() {
        return ratingsCount;
    }

    public void setRatingsCount(Integer ratingsCount) {
        this.ratingsCount = ratingsCount;
    }

    public Integer getRatingsSum() {
        return ratingsSum;
    }

    public void setRatingsSum(Integer ratingsSum) {
        this.ratingsSum = ratingsSum;
    }
}
